package cn.goktech.sports.common.utils.richText;

import com.alibaba.fastjson.JSONException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.goktech.sports.common.annotation.RestAnon;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Api(value = "百度富文本", description = "百度富文本")
@RestController
@RequestMapping("/rest")
public class RichTextController {
	@RequestMapping("/RichTextConfig")
	@ApiOperation(value = "百度富文本")
	@RestAnon
	public void getRichTextConfig(HttpServletResponse response, HttpServletRequest request){
		response.setHeader("Content-Type" , "text/html");
		String rootPath = "config.json";
		try {
			String exec = new ActionEnter(request, rootPath).exec();
			PrintWriter writer = response.getWriter();
			writer.write(exec);
			writer.flush();
			writer.close();
		} catch (IOException | JSONException e) {
			e.printStackTrace();
		}
	}

}
